﻿using Camc.Quality.Configuration;
using Camc.Quality.Web;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Camc.Quality.EntityFrameworkCore
{
    public class SCDContextFactory : IDesignTimeDbContextFactory<SCDDbContext>
    {
        public SCDDbContext CreateDbContext(string[] args)
        {
            var builder = new DbContextOptionsBuilder<SCDDbContext>();
            var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder(), addUserSecrets: true);

            SCDDbContextOptionsConfigurer.Configure(builder,
                configuration.GetConnectionString(QualityConsts.SecondDbConnectionStringName));

            return new SCDDbContext(builder.Options);
        }
    }
}
